__author__ = 'Administrator'
from django import template

register = template.Library()

def ts(d,key_name):
    value = 0
    try:
      value = d[key_name]['count']['transmit-bytes-speed']
    except KeyError:
      value = 0
    return value

def rs(d,key_name):
    value = 0
    try:
      value = d[key_name]['count']['receive-bytes-speed']
    except KeyError:
      value = 0
    return value

def rb(d,key_name):
    value = 0
    try:
      value = d[key_name]['count']['receive-bytes']
    except KeyError:
      value = 0
    return value

def tb(d,key_name):
    value = 0
    try:
      value = d[key_name]['count']['transmit-bytes']
    except KeyError:
      value = 0
    return value

register.filter('ts',ts)
register.filter('rs',rs)
register.filter('rb',rb)
register.filter('tb',tb)